﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using RoadTeam.Model;
using RoadTeam.Model.CS;
using RoadTeam.SysInterface;
using RoadTeam.Enums;

namespace RoadTeam.CsSystem.CS
{
    class CsListItem : ICsListItem
    {
        public DataTable GetAllCsListItemFromRoadTeamSystem()
        {
            客服_收楼维修项目 listItem = new 客服_收楼维修项目();
            SqlWhere where = new SqlWhere();
            where.StrSqlWhere = @" APP标识量 IS NULL ";
            where.SelectColumn = @" id,项目名称,项目内容,说明,APP标识量 ";
            DataTable dt = 客服_收楼维修项目.Select(where, GlobalConfig.RtConnectionString);
            return dt;
        }


        public bool UpdateCsListItemToRoadTeamSystem(DataTable dt)
        {
            客服_收楼维修项目 listItem = new 客服_收楼维修项目();
            return 客服_收楼维修项目.Update(dt, GlobalConfig.RtConnectionString);
        }


        public int GetCsListItemIDFromSystem(String Identifier)
        {
            return GetCsListItemIDFromSystem(Identifier, GlobalConfig.RtConnectionString);
        }


        private int GetCsListItemIDFromSystem(String Identifier, String ConStr)
        {
            客服_收楼维修项目 listItem = new 客服_收楼维修项目();
            SqlWhere where = new SqlWhere();
            where.Info = new 客服_收楼维修项目() { APP标识量 = Identifier };

            DataTable dt = 客服_收楼维修项目.Select(where, ConStr);
            if (dt.Rows.Count == 0) return -1;
            return Convert.ToInt32(dt.Rows[0]["id"]);

        }
    }
}
